package com.cloudera;

import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;

/**
 * Created by shuyun on 2016/8/24.
 */
public class RecentNameSelector extends UDF {
    public Text evaluate(Text recentName, Text mostName, Text modifyName, IntWritable priority) {
        if(null != modifyName && 0 < modifyName.toString().trim().length())
            return new Text(modifyName.toString());

        if(null == priority || priority.get() == 0)
            if (null == recentName)
                return null;
            else
                return new Text(recentName.toString());

        if (null == mostName)
            return null;
        else
            return new Text(mostName.toString());
    }
}
